﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
namespace lcs.Web.demandplaninfo
{
    public partial class Show : Page
    {
        public string strid = "";
        decimal mysum= 0;        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    strid = Request.Params["id"];
                    int dpid = (Convert.ToInt32(strid));
                    ShowInfo(dpid);
                }
            }
        }

        private void ShowInfo(int dpid)
        {
            lcs.BLL.demandplaninfo bll = new lcs.BLL.demandplaninfo();
            DataSet ds = bll.GetList(" and dpid="+dpid);
            if (ds.Tables[0].Rows.Count == 1)
            {
                this.lbldepname.Text = ds.Tables[0].Rows[0]["depname"].ToString();
                this.lblprojectname.Text = ds.Tables[0].Rows[0]["projectName"].ToString();
                this.lblprojecttype.Text = ds.Tables[0].Rows[0]["projectTypeName"].ToString();
                this.lblinputtime.Text = ds.Tables[0].Rows[0]["inputtime"].ToString();
                this.hlfile.NavigateUrl = ds.Tables[0].Rows[0]["skillfile"].ToString();
                this.lblinvoicetype.Text = ds.Tables[0].Rows[0]["invoicetype"].ToString();
                lcs.BLL.demandmaterialinfo mbll = new lcs.BLL.demandmaterialinfo();
                DataSet mds = mbll.GetList(" and dpid=" + dpid);
                gridView.DataSource = mds;
                gridView.DataBind();
            }

        }

        protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DataRowView myrows = (DataRowView)e.Row.DataItem;
                mysum+= Convert.ToDecimal(myrows[6].ToString());                
            }
            // 合计
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[0].Text = "合计";
                e.Row.Cells[6].Text = mysum.ToString();                
            }
        }


    }
}
